<template>
  <div class="info-attr-module">
    <div class="title">赛事信息</div>
    <div class="attr-data">
      <div class="item">
        <span>赛事名称</span>
        <div>第七届全国青少年无人机大赛</div>
      </div>
      <div class="item">
        <span>选手姓名</span>
        <div>三粒儿</div>
      </div>
      <div class="item">
        <span>参与赛项</span>
        <div>空中格斗赛</div>
      </div>
      <div class="item">
        <span>参赛组别</span>
        <div>初中组</div>
      </div>
      <div class="item">
        <span>获奖证书</span>
        <div class="link">下载证书</div>
      </div>

      <div class="certificate">
        <img
          class="img"
          src="https://img0.baidu.com/it/u=3455200186,3615733310&fm=253&fmt=auto&app=138&f=JPG?w=499&h=353"
        />
      </div>
    </div>
    <div style="height: 4rem"></div>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue";
import {useRoute} from "vue-router";
import baseService from "@/service/baseService";
import {ElMessage} from "element-plus";
import app from "@/constants/app";
import {getCache} from "@/utils/cache";
const route = useRoute();

const tableData = reactive({
  list: []
});

const showViewUrlFlag = ref(false);


const certificateJson = getCache('certificate', { isSessionStorage: true }, {});
const realName = certificateJson.realName;
const idCard = certificateJson.idCard;
const certificate = certificateJson.certificate;

//查看证书
const viewUrl = (url: string) => {
  window.open(url);
};

// 查询证书
const queryCertificateBy = () => {
  baseService
      .post("/front/spuser/queryCertificateBy", {realName, idCard, certificate})
      .then((res) => {
            if (res.code === 0) {
              tableData.list = res.data;
            } else {
              ElMessage.error(res.msg);
            }
          }
      );
};

const downLoadFile = (url: string, name: string) => {
  let a = document.createElement('a');
  let evt = document.createEvent('MouseEvents');
  a.download = '晋级列表';
  a.href = app.api+"/front/download?imageUrl="+ url +"&fileName=" + name;
  evt.initEvent('click',true,true);
  a.dispatchEvent(evt);
  window.URL.revokeObjectURL(a.href);
}


queryCertificateBy();

</script>

<style lang="scss" scoped>
@import "./style.scss";
</style>
